package com.karrim.server.io.sql;

import com.google.inject.Inject;
import com.karrim.server.annotation.Annotation.MySQLConnectionString;

/**
 *
 * @author andrea.cantafio
 */
public class MySQLConnector extends AbstractSQLStream {

    public MySQLConnector(String host, String database) throws ClassNotFoundException {
        this(host, 3306, database);
    }

    public MySQLConnector(String host, int port, String database) throws ClassNotFoundException {
        this(host, port, database, "", "");
    }

    public MySQLConnector(String host, String database, String user, String pass) throws ClassNotFoundException {
        this("jdbc:mysql://" + host + ":3306/" + database + "?user=" + user + "&pass=" + pass);
    }

    public MySQLConnector(String host, int port, String database, String user, String pass) throws ClassNotFoundException {
        this("jdbc:mysql://" + host + ':' + port + '/' + database + "?user=" + user + "&pass=" + pass);
    }

    @Inject
    public MySQLConnector(@MySQLConnectionString String connectionString) throws ClassNotFoundException {
        super(connectionString, "com.mysql.jdbc.Driver");
    }
}
